package cn.edu.nit.sys.controller;

import cn.edu.nit.sys.config.OperationAnnotation;
import cn.edu.nit.sys.dto.StudentDTO;
import cn.edu.nit.sys.entity.Student;
import cn.edu.nit.sys.service.StudentService;
import cn.edu.nit.sys.utils.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/student")
public class StudentController {

    @Autowired
    private StudentService studentService;

    @GetMapping
//    @PreAuthorize("hasAuthority('ADMIN')")
    @OperationAnnotation(description = "获取学生信息列表", opType = "查询")
    public R getList(Page<StudentDTO> page, String siftName, String deptId, String majorId) {
        return studentService.getStudentList(page, siftName, deptId, majorId);
    }

    @GetMapping("/{id}")
    public R getDetail(@PathVariable("id")String id) {
        return R.ok(studentService.getById(id));
    }

    @DeleteMapping("/{id}")
    public R delStudent(@PathVariable("id")String id) {
        return studentService.removeStudent(id);
    }
}
